//
//  CXHHttpOperation.h
//  CXHNetworking
//
//  Created by Cdionysus on 2018/12/7.
//  Copyright © 2018年 Cdionysus. All rights reserved.
//

#import <Foundation/Foundation.h>

@class CXHHttpOperation;
typedef void(^CXHHttpOperationCompletionBlock)(CXHHttpOperation *operation, NSURLSessionDataTask *dataTask, NSData *data, NSError *error);

@interface CXHHttpOperation : NSOperation

@property (nonatomic, strong, readonly) NSURLRequest *URLRequest;
@property (nonatomic, strong, readonly) NSURLSessionDataTask *dataTask;

@property (nonatomic, readonly, strong) NSURLResponse *response;
@property (nonatomic, readonly, strong) NSData *responseObject;
@property (nonatomic, readonly, strong) NSError *error;

+ (instancetype)operationWithRequest:(NSURLRequest *)URLRequest;
- (instancetype)initWithRequest:(NSURLRequest *)URLRequest;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)new NS_UNAVAILABLE;

- (void)setCompletion:(CXHHttpOperationCompletionBlock)completion;

@end
